﻿/*
 * 选择检验依据。
 * 
 * 由于检验依据变更为针对产品的模板，这个已经不需要了。2010-1-7
 * 
 * 
 * 
 * **/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EQT.Dal;
using EQT.Model;
public partial class SetCGB : System.Web.UI.Page
{
    private DaContractgb dacgb = DevFuture.Common.WorkContext.AppCtx.GetObject("DaContractgb") as DaContractgb;
    private DaGbinfo dagb = DevFuture.Common.WorkContext.AppCtx.GetObject("DaGbinfo") as DaGbinfo;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string report_id = Request.QueryString["report_id"];
            if (String.IsNullOrEmpty(report_id))
            {
                Utility.SiteError("缺失所必需的参数【合同编号】", Response);
                return;
            }
            else
            {
                LabelReportID.Text = report_id;
                ViewState["REPORT_ID"] = report_id;
                BindGbInfo2Select();
            }
        }

    }


    private void BindGbInfo2Select()
    {
        //在这里绑定GbInfo
        DataSet ds = dagb.GetGb2Selected(ViewState["REPORT_ID"].ToString());
        DropDownListGbInfo.DataSource = ds;
        DropDownListGbInfo.DataTextField = "Gb_Code";//
        DropDownListGbInfo.DataValueField = "Gb_Code";//都以代码为文字
        DropDownListGbInfo.DataBind();
        if (DropDownListGbInfo.Items.Count > 0)
        {
            DropDownListGbInfo.SelectedIndex = 0;
            DataRow dr = ds.Tables[0].Rows[0];
            MoGbinfo mo = new MoGbinfo();
            mo.Row2Model(dr);
            TextBoxGbTitle.Text = mo.GbTitle;
            TextBoxGbSubject.Text = mo.GbSubject;
            TextBoxGbStatus.Text = mo.GbStatus == 0 ? "在用" : "过期";
            TextBoxGbRem.Text = mo.Rem;
        }
    }

    protected void DropDownListGbInfo_SelectedIndexChanged(object sender, EventArgs e)
    {
        string gb_code = DropDownListGbInfo.SelectedValue;
        if (!String.IsNullOrEmpty(gb_code))
        {
            MoGbinfo mo = new MoGbinfo();
            mo.GbCode = gb_code;
            dagb.GetEntityEx(ref mo);
            TextBoxGbTitle.Text = mo.GbTitle;
            TextBoxGbSubject.Text = mo.GbSubject;
            TextBoxGbStatus.Text = mo.GbStatus == 0 ? "在用" : "过期";
            TextBoxGbRem.Text = mo.Rem;
        }
        
    }

    protected void btnGbInfoSelectOK_Click(object sender, EventArgs e)
    {
        //设定报告的检验项         
        dacgb.Add(new MoContractgb(DropDownListGbInfo.SelectedValue, ViewState["REPORT_ID"].ToString()));
        //回发后自动关闭        
        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "UpdatePanel1", "window.returnValue=true;window.close();", true);
    }
}
